package com.neuedu.mybatis;

import com.neuedu.mybatis.dao.DeptMapper;
import com.neuedu.mybatis.po.Dept;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @author 金山
 * 项目：mybatis-review
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2025/3/611:34
 */
public class Runner {


    public static void main(String[] args) throws IOException {


        String resource = "mybatis-config.xml";
        InputStream resourceAsStream = Resources.getResourceAsStream(resource);

        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);

        //数据库的会话
        SqlSession session = sqlSessionFactory.openSession();


        //获取代理
        DeptMapper mapper = session.getMapper(DeptMapper.class);

        Dept dept = mapper.selectOneItem();

        System.out.println("dept = " + dept);


        // List<Dept> depts = mapper.selectOneItem2();
        // System.out.println("depts = " + depts);

    }
}
